home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
- Begin VB.Form frmSQLTester
- BorderStyle = 1 'Fixed Single
- Caption = "SQL Tester"
- ClientHeight = 3540
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 6360
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3540
- ScaleWidth = 6360
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton cmdTest
- Caption = "Test SQL Statement"
- Height = 495
- Left = 4080
- TabIndex = 4
- TabStop = 0 'False
- Top = 1920
- Width = 2175
- End
- Begin VB.TextBox txtSQLTester
- Height = 1575
- Left = 120
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 3
- Top = 1920
- Width = 3855
- End
- Begin MSDBGrid.DBGrid grdSQLTester
- Bindings = "Exercise5.frx":0000
- Height = 1695
- Left = 120
- OleObjectBlob = "Exercise5.frx":0030
- TabIndex = 2
- TabStop = 0 'False
- Top = 120
- Width = 6135
- End
- Begin VB.Data datSQLTester
- Caption = "SQL Tester"
- Connect = "Access"
- DatabaseName = "c:\VBDB\Working\Nwind.mdb"
- DefaultCursorType= 0 'DefaultCursor
- DefaultType = 2 'UseODBC
- Exclusive = 0 'False
- Height = 345
- Left = 4080
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = ""
- Top = 3120
- Width = 2220
- End
- Begin VB.Label lblRecords
- Alignment = 2 'Center
- BackColor = &H00FFFFFF&
- BorderStyle = 1 'Fixed Single
- Caption = "0"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 5040
- TabIndex = 1
- Top = 2520
- Width = 1215
- End
- Begin VB.Label Label1
- Caption = "Records Returned"
- Height = 495
- Left = 4080
- TabIndex = 0
- Top = 2520
- Width = 1215
- End
- Attribute VB_Name = "frmSQLTester"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub cmdTest_Click()
- 'Enable error handling
- On Error GoTo SQLError
- 'Read SQL statement and establish Recordsource
- datSQLTester.RecordSource = txtSQLTester.Text
- datSQLTester.Refresh
- 'Count records
- datSQLTester.Recordset.MoveLast
- datSQLTester.Recordset.MoveFirst
- lblRecords.Caption = datSQLTester.Recordset.RecordCount
- txtSQLTester.SetFocus
- Exit Sub
- 'If error occurs, report it in message box
- SQLError:
- MsgBox Error(Err.Number), vbExclamation + vbOKOnly, "SQL Error"
- Exit Sub
- End Sub
-